import type { Ref } from 'vue';

import { $t } from '#/locales';

export interface LeftSideItem {
  name: string;
  menu: string;
  count: Ref<number>;
}

/** 跟进状态 */
export const FOLLOWUP_STATUS = [
  { label: 'views.crm.todo.statusOptions.followUpStatus.pending', value: false },
  { label: 'views.crm.todo.statusOptions.followUpStatus.done', value: true },
];

/** 归属范围 */
export const SCENE_TYPES = [
  { label: 'views.crm.todo.statusOptions.sceneType.my', value: 1 },
  { label: 'views.crm.todo.statusOptions.sceneType.participated', value: 2 },
  { label: 'views.crm.todo.statusOptions.sceneType.subordinate', value: 3 },
];

/** 联系状态 */
export const CONTACT_STATUS = [
  { label: 'views.crm.todo.statusOptions.contactStatus.contactToday', value: 1 },
  { label: 'views.crm.todo.statusOptions.contactStatus.delay', value: 2 },
  { label: 'views.crm.todo.statusOptions.contactStatus.done', value: 3 },
];

/** 审批状态 */
export const AUDIT_STATUS = [
  { label: 'views.crm.todo.statusOptions.auditStatus.pending', value: 10 },
  { label: 'views.crm.todo.statusOptions.auditStatus.pass', value: 20 },
  { label: 'views.crm.todo.statusOptions.auditStatus.reject', value: 30 },
];

/** 回款提醒类型 */
export const RECEIVABLE_REMIND_TYPE = [
  { label: 'views.crm.todo.statusOptions.receivableRemindType.pending', value: 1 },
  { label: 'views.crm.todo.statusOptions.receivableRemindType.delay', value: 2 },
  { label: 'views.crm.todo.statusOptions.receivableRemindType.done', value: 3 },
];

/** 合同过期状态 */
export const CONTRACT_EXPIRY_TYPE = [
  { label: 'views.crm.todo.statusOptions.contactExpiryType.toBeExpired', value: 1 },
  { label: 'views.crm.todo.statusOptions.contactExpiryType.expired', value: 2 },
];

export const convertOptions = (options: any) => {
  let newOptions : any[] = []
  options.forEach((item: any) => { 
    newOptions.push({
      label: $t(item.label),
      value: item.value
    })
  })
  return newOptions;
};

/** 左侧菜单 */
export const useLeftSides = (
  customerTodayContactCount: Ref<number>,
  clueFollowCount: Ref<number>,
  customerFollowCount: Ref<number>,
  customerPutPoolRemindCount: Ref<number>,
  contractAuditCount: Ref<number>,
  contractRemindCount: Ref<number>,
  receivableAuditCount: Ref<number>,
  receivablePlanRemindCount: Ref<number>,
): LeftSideItem[] => {
  return [
    {
      name: $t('views.crm.todo.leftSideItem.customerTodayContact'),
      menu: 'customerTodayContact',
      count: customerTodayContactCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.clueFollow'),
      menu: 'clueFollow',
      count: clueFollowCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.customerFollow'),
      menu: 'customerFollow',
      count: customerFollowCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.customerPutPoolRemind'),
      menu: 'customerPutPoolRemind',
      count: customerPutPoolRemindCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.contractAudit'),
      menu: 'contractAudit',
      count: contractAuditCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.receivableAudit'),
      menu: 'receivableAudit',
      count: receivableAuditCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.receivablePlanRemind'),
      menu: 'receivablePlanRemind',
      count: receivablePlanRemindCount,
    },
    {
      name: $t('views.crm.todo.leftSideItem.contractRemind'),
      menu: 'contractRemind',
      count: contractRemindCount,
    },
  ];
};
